<script type="text/html" template lay-done="layui.data.done(d.params)">
  <div class="layui-form" lay-filter="form_online">
    {{# var data = d.params || {} }}
    <div class="layui-form-item">
      <label class="layui-form-label">用户手机号</label>
      <div class="layui-input-inline">
        <input type="hidden" name="id" value="{{data.id || ''}}"/>
        {{# if (data.user) { }}
        <input type="text" class="layui-input" value="{{data.user.mobile || ''}}" readonly/>
        {{# }else{ }}
        <input type="text" name="mobile" class="layui-input" value=""/>
        {{# } }}
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">用户等级</label>
      <div class="layui-input-inline" style="width: 100px">
        <select name="level" lay-verify="required">
          <option>1</option>
          <option>2</option>
          <option>3</option>
          <option>4</option>
          <option>5</option>
        </select>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label form-required">抽奖次数</label>
      <div class="layui-input-inline">
        <input type="number" class="layui-input" name="available_times" style="width: 100px"
               autocomplete="off" value="{{data.available_times || ''}}" lay-verify="required">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label"></label>
      <div class="layui-word-aux layui-form-mid">
        实际可抽奖次数 = 抽奖次数 - 已抽奖次数({{data.draw_times || 0}}次)
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label"></label>
      <div class="layui-input-inline">
        <input type="hidden" name="id" value="{{data.id || ''}}"/>
        <input type="hidden" name="lottery_id" value="{{data.lottery_id || ''}}"/>
        <a class="layui-btn" lay-submit lay-filter="submit_lottery_user">保存</a>
      </div>
    </div>
  </div>
</script>
<script>
  layui.data.done = function (obj) {
    console.log(obj)
    layui.use([], function () {
      let $ = layui.$
        , form = layui.form
        , admin = layui.admin
      if (obj.level) {
        $('select[name="level"]').val(obj.level)
      }
      form.render()
    })
  }
</script>

